
package BLogic;

import HibernateLayer.SessionExausedExcepion;
import HibernateLayer.VDocumentServices;
import POJOs.salary;
import POJOs.worker;
import java.io.File;
import java.util.GregorianCalendar;
import org.hibernate.Session;

/**
 *
 * @author fabiofurlan
 */
public class VDocumentZipService extends VZipManager<worker> {

    private Session basicSession;

    public Session getBasicSession() {
        return basicSession;
    }

    public void setBasicSession(Session basicSession) {
        this.basicSession = basicSession;
    }

    @Override
    protected void dbWriter(worker user, String fileName, File toWrite, String comm) throws SessionExausedExcepion{

        VDocumentServices docServices=new VDocumentServices(this.basicSession);
        salary newsalary=new salary();
        GregorianCalendar calendar= new GregorianCalendar();
        int todayDay=calendar.get(calendar.DATE);
        int todayMonth=calendar.get(calendar.MONTH)+1; //Mounth start from zero.
        int todayYear=calendar.get(calendar.YEAR);


        newsalary.setDocument(toWrite);
        newsalary.setDescription(comm);
        newsalary.setFiletype(fileName);
        newsalary.setFiletype("pdf");
        newsalary.setWorker(user);
        newsalary.setDay(todayDay);
        newsalary.setMonth(todayMonth);
        newsalary.setYear(todayYear);

        docServices.createBasicStructure(newsalary);
    }

}
